//
//  GCDExample.m
//  LSCodeLibrary
//
//  Created by Samuel on 15/4/2.
//  Copyright (c) 2015年 Samuel. All rights reserved.
//

#import "GCDExample.h"

@implementation GCDExample

- (void)testFuntion;
{
    //
    //    (void)(^aatest)(void);
    //
    //    aatest = ^{
    //        NSLog(@"fasdfasdf");
    //    }
    //
    //
    //    logerBlock();
    //后台执行
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        ;
    });
    //主线成
    dispatch_async(dispatch_get_main_queue(), ^{
        ;
    });
    //一次执行
    static dispatch_once_t oneceTaken;
    dispatch_once(&oneceTaken, ^{
        ;
    });
    //时间控制执行
    double a = 2.0f;
    dispatch_time_t b = dispatch_time(DISPATCH_TIME_NOW, a *NSEC_PER_SEC);
    dispatch_after(b, dispatch_get_main_queue(), ^{
        ;
    });
    //并发执行
    dispatch_group_t groups = dispatch_group_create();
    //并发1
    dispatch_group_async(groups, dispatch_get_global_queue(0, 0), ^{
        ;
    });
    //并发2
    dispatch_group_async(groups, dispatch_get_global_queue(0, 0), ^{
        ;
    });
    //汇总结果
    dispatch_group_notify(groups, dispatch_get_global_queue(0, 0), ^{
        ;
    });
    
    //    __block int a = 0;
    //    void (^foo)(void) = ^{
    //        a= 1;
    //    };
    //    foo();
    
}

@end
